package com.zuihai.app.mvp.ui.utils;

import com.zuihai.app.mvp.model.entity.InitUser;

import org.litepal.crud.DataSupport;

/**
 * Created by Administrator on 2017/6/9 0009.
 * 用户帮助类
 */
public class AccountHelper {

    private static AccountHelper mInstance;

    private AccountHelper() {
    }

    public static AccountHelper getInstance(){
        if (mInstance == null){
            synchronized (AccountHelper.class){
                if (mInstance == null){
                    mInstance = new AccountHelper();
                }
            }
        }
        return mInstance;
    }

    /**
     * 是否登录
     * @return
     */
    public boolean isLogin(){
        return getAccount() != null;

    }

    /**
     * 获取用户实体
     * @return
     */
    public InitUser getAccount(){
        return DataSupport.findFirst(InitUser.class);
    }

    /**
     * 获取用户ID
     * @return
     */
    public String getUid(){
        return getAccount() != null ? getAccount().getUid() : "-1";
    }

    /**
     * 获取用户名
     * @return
     */
    public String getName(){
        return getAccount() != null ? getAccount().getName() : "";
    }

    /**
     * 获取用户头像
     * @return
     */
    public String getAvatar(){
        return getAccount() != null ? getAccount().getIcon() : "";
    }

    /**
     * 获取用户签名
     * @return
     */
    public String getMemo(){
        return getAccount() != null ? getAccount().getQianMing() : "";
    }
}
